//
//  DAnalysisTitleHeaderView.swift
//  Drop
//
//  Created by hushaohua on 2018/4/27.
//  Copyright © 2018年 init. All rights reserved.
//

import UIKit

class DAnalysisTitleHeaderView: UITableViewHeaderFooterView {

    lazy var tagLabel:UILabel = {
        var label:UILabel = UILabel(frame: .zero);
        label.text = "TAG";
        label.textColor = UIColor.lightGray;
        label.font = UIFont.systemFont(ofSize: 13);
        label.translatesAutoresizingMaskIntoConstraints = false;
        return label;
    }();
    lazy var timeLabel:UILabel = {
        var label:UILabel = UILabel(frame: .zero);
        label.text = "时间";
        label.textAlignment = .right;
        label.textColor = UIColor.lightGray;
        label.font = UIFont.systemFont(ofSize: 13);
        label.translatesAutoresizingMaskIntoConstraints = false;
        return label;
    }();
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier);
        self.contentView.addSubview(self.tagLabel);
        self.contentView.addSubview(self.timeLabel);
        self.addSubviewConstraints();
    }
    
    func addSubviewConstraints(){
        var constraints:[NSLayoutConstraint] = [NSLayoutConstraint]();
        let views:[String : Any] = ["tag" : self.tagLabel, "time" : self.timeLabel];
        constraints += NSLayoutConstraint.constraints(withVisualFormat: "H:|-30-[tag]-[time(==80)]-40-|", options: .directionLeadingToTrailing, metrics: nil, views: views);
        constraints += NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[tag]-0-|", options: .directionLeadingToTrailing, metrics: nil, views: views);
        constraints += NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[time]-0-|", options: .directionLeadingToTrailing, metrics: nil, views: views);
        NSLayoutConstraint.activate(constraints);
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
